import React from "react";
class RefCom extends React.Component{
    constructor(){
        super();
        this.pass=React.createRef();
    }
    getbox=()=>{
        
        // console.log(this.box.innerHTML);
        // console.log(this.username.value);

        // this.username.value="你好"

        console.log(this.pass.current.value);
    }
    render(){
    return (
        <div>ref

            <div ref={c=>this.box=c}>ref操作dom</div>
            <input ref={c=>this.username=c} type="text" />
            <input ref={this.pass} type="text" />

            <button onClick={this.getbox}>btn</button>

        

        </div>
    )
    }
}
export default RefCom;